fix(mysql): fail fast on partial JSON binlog events (PARTIAL_JSON)#4538
Merged
Conversation
When binlog_row_value_options=PARTIAL_JSON is enabled at runtime on the source, MySQL emits PARTIAL_UPDATE_ROWS_EVENT carrying JSON diffs instead of full values. go-mysql parses these as a *RowsEvent, but PeerDB's inner event-type switch had no case for it and no default, so the entire update (all columns) was silently dropped after its bytes were counted as consumed — CDC advanced past it, causing silent data loss. Add a PARTIAL_UPDATE_ROWS_EVENT case that fails fast with a classified error (NOTIFY_BINLOG_PARTIAL_JSON_UNSUPPORTED) telling the user to disable binlog_row_value_options and resync, plus a default branch so any future rows-event subtype errors loudly instead of dropping data. The JsonDiff value conversion now errors as a defensive backstop. Scoped to tables in the pipe via the existing `schema != nil` guard. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
Author
|
Companion PRs (final links):
|
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
1 similar comment
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
jgao54
approved these changes
Jul 6, 2026
ilidemi
reviewed
Jul 7, 2026
| } | ||
|
|
||
| if _, ok := errors.AsType[*exceptions.MySQLUnsupportedBinlogRowValueOptionsError](err); ok { | ||
| return ErrorNotifyBinlogPartialJsonUnsupported, ErrorInfo{ |
Contributor
There was a problem hiding this comment.
If we're doing custom notification, can include AdditionalAttributes here as well
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
binlog_row_value_optionsis a dynamic, session-settable MySQL variable, so it can be set toPARTIAL_JSONat runtime after a mirror passes creation-time validation. When enabled, MySQL emitsPARTIAL_UPDATE_ROWS_EVENT(event type 39) carrying JSON diffs instead of full column values.go-mysql parses these into a
*replication.RowsEvent, so the event reaches PeerDB'scase *replication.RowsEvent:normally. But the inner event-type switch had no case forPARTIAL_UPDATE_ROWS_EVENTand nodefault— so the entire update (all columns, not just the JSON one) was silently dropped after its bytes were already counted as consumed. CDC advanced past it → silent data loss.Fix
PARTIAL_UPDATE_ROWS_EVENTcase that fails fast with a new classified error (MySQLUnsupportedBinlogRowValueOptionsError→NOTIFY_BINLOG_PARTIAL_JSON_UNSUPPORTED), instructing the user to disablebinlog_row_value_optionsand resync.🤖 Generated with Claude Code